/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package net.wofly.cashier.table.repository;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import net.wofly.cashier.table.domain.Table;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface TableRepository
		extends PagingAndSortingRepository<Table, String>, JpaSpecificationExecutor<Table> {

	List<Table> findByTableIDAndStatus(String tableID, Integer status);

	List<Table> findByTableNameAndStatus(String tableName, Integer status);

	@Query("update Table set status = :status where tableID = :tableID")
	@Modifying
	void updateStatusByTableID(@Param("status") Integer status, @Param("tableID") String tableID);

	List<Table> findByStatus(Integer status);
}